/*
 *   Copyright 2009 Sukharev Eduard <kraplax@mail.ru>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef NULLBYTE_POSTITEM_H
#define NULLBYTE_POSTITEM_H

#include <QVariant>
#include <QMap>
#include <QString>

/**
 * @brief Class for representing a single post
 *
 * PostItem holds information of a single post and provides convinient way to access it.
 *
 * The class's objects require QVariant or QMap<QString, QVariant> that holds all the data
 * that a single post consists of. Normally you'd create an object from QMap["arr"].toList()
 * elements (from QVariant), or from QMap<QString, QVariant> that is just the same
 * QVariant.toMap().
 * For getting the parsed output you'd want to use getFormattedString(), which would return
 * QString with basic formatting.
 */
class PostItem : public QObject
{
Q_OBJECT;

public:
    /**
    * The constructor for PostItem class. Get's raw QVariant to be created from.
    * 
    * @param postVariant the QVariant variable that contains the whole post data
    */
    PostItem(QVariant postVariant);
    
    /**
    * This is overloaded constructor. It creates PostItem object from 
    * QMap<QString, QVariant>.
    *
    * @param postMap the QMap<QString, QVariant> that is just the same QVariant.toMap()
    */
    PostItem(QMap<QString, QVariant> postMap);
    ~PostItem();
    
    /**
    * Returns preparsed and preformatted post info in a single QString.
    * 
    * The output is hardcoded, but should be configurable in 
    * Perfect World. Since we all live in Real World this goes to the
    * WISHES list.
    */
    QString getFormattedString();
    
    //QMap getElementMap();
    
private:
    int id, rating;
    QString title, user, url;
};

#endif // NULLBYTE_POSTITEM_H
